package com.esri.core.map;

import com.esri.core.internal.util.d;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class FeatureType implements Serializable {
    private static final long serialVersionUID = 1;
    private String a;
    private String b;
    private HashMap<String, Domain> c;
    private List<FeatureTemplate> d;

    public FeatureType() {
    }

    public FeatureType(String str, String str2, HashMap<String, Domain> hashMap) {
        this.a = str;
        this.b = str2;
        this.c = hashMap;
    }

    public FeatureType(String str, String str2, List<FeatureTemplate> list) {
        this.a = str;
        this.b = str2;
        this.d = list;
    }

    public HashMap<String, Domain> getDomains() {
        return this.c;
    }

    public String getId() {
        return this.a;
    }

    public String getName() {
        return this.b;
    }

    public FeatureTemplate[] getTemplates() {
        List<FeatureTemplate> list = this.d;
        if (list == null) {
            return null;
        }
        return (FeatureTemplate[]) list.toArray(new FeatureTemplate[0]);
    }

    void a(List<FeatureTemplate> list) {
        this.d = list;
    }

    public String toString() {
        return "Type: [ id: " + this.a + ", name: " + this.b + ", domains: " + this.c + "]";
    }

    public static FeatureType fromJson(JsonParser jsonParser) throws Exception {
        if (d.c(jsonParser)) {
            FeatureType featureType = new FeatureType();
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                String currentName = jsonParser.getCurrentName();
                jsonParser.nextToken();
                if ("id".equals(currentName)) {
                    featureType.a = jsonParser.getText();
                } else if ("name".equals(currentName)) {
                    featureType.b = jsonParser.getText();
                } else if ("domains".equals(currentName)) {
                    featureType.c = a(jsonParser);
                } else if ("templates".equals(currentName)) {
                    if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                        featureType.d = new ArrayList();
                        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                            featureType.d.add(FeatureTemplate.fromJson(jsonParser));
                        }
                    }
                } else {
                    jsonParser.skipChildren();
                }
            }
            return featureType;
        }
        return null;
    }

    private static HashMap<String, Domain> a(JsonParser jsonParser) throws Exception {
        HashMap<String, Domain> hashMap = new HashMap<>();
        if (d.c(jsonParser)) {
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                String currentName = jsonParser.getCurrentName();
                jsonParser.nextToken();
                hashMap.put(currentName, Domain.fromJson(jsonParser));
            }
            return hashMap;
        }
        return null;
    }
}
